package so.wy.servicecenter.businessbed.dao.enums;

/**
 * 支付状态
 */
public enum StatusPayEnum {
    /**
     * 创建
     */
    CREATE(1, "创建"),
    /**
     * 处理中
     */
    PROCESSING(2, "处理中"),
    /**
     * 成功
     */
    SUCCESS(3, "成功"),
    /**
     * 失败
     */
    FAIL(4, "失败"),
    /**
     * 已退款
     */
    REFUNDED(5, "已退款");
    private Integer code;
    private String name;

    StatusPayEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static StatusPayEnum codeOf(Integer code) {
        if (code == null) {
            return null;
        }

        StatusPayEnum[] values = values();
        for (StatusPayEnum value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static String codeOfDesc(Integer code) {
        StatusPayEnum value = codeOf(code);

        return value == null ? "" : value.getName();
    }
}